﻿<!DOCTYPE>
<html>
<head>
<script>
function myFunction(trnpid)
{
var r=confirm("Bạn có chắc muốn xóa chương trình đào tạo "+trnpid+" không ? ");
if (r==true)
  {
  document.location = "control/staff-proc-del-trnp.php?trnpid="+trnpid;
  }
else
  {
  }

}
</script>
<!-- CSS goes in the document HEAD or added to your external stylesheet -->
<link rel="stylesheet" href="styles/staff.css" type="text/css" />
<style>
table,td,th
td
{
text-align:center;
}
#trnpname{
    width: 300px;
}
</style>
</head>
<body>



<?php
require("model/connect.php");

$baitren_mottrang = 5;

if ( !isset($_GET['page']) )
{
    $page = 0 ;
}else
{
    $page= $_GET['page'];
}
$sodu_lieu = mysql_num_rows(mysql_query("SELECT * FROM `trainningprogram` ") ) or die(mysql_error());

$sotrang = $sodu_lieu/$baitren_mottrang;

$result =mysql_query("SELECT * FROM `trainningprogram` LIMIT ".$page*$baitren_mottrang.",".$baitren_mottrang) or die(mysql_error());
?>
<table class="gridtable">
<tr>
	<th>Mã khóa học</th><th>Tên khóa học</th><th>Ngày bắt dầu</th><th>Tùy chọn</th>
</tr>
<tr>
<form action="control/staff-proc-add-trnp.php" method="POST">
<td><input type="text" name="trnpid" required /></td><td><input type="text" name="trnpname" id="trnpname" width="50" required/></td><td><input type="date" name="trnpdate" required/></td><td><input type="submit" value="Thêm"/></td>
</form>

</tr>
<?php
while ( $info = mysql_fetch_array($result )) 
{
    ?>
<tr>
<form action="control/staff-proc-edit-trnp.php" method="POST">
	<td><?php echo $info[0]?></td><td><input type="hidden" value="<?php echo "".$page?>" name="page"/><input type="hidden" name="trnpid" value="<?php echo  $info[0]?>"/><input type="text" name="trnpname" id="trnpname" value="<?php echo  $info[1]?>"/></td><td><input type="date" name="trnpdate" value="<?php echo $info[2]?>"/></td><td><input type="submit" value="Sửa"/></td>
</form>
<td><button onclick="myFunction('<?php echo "".$info[0]; ?>')">Xóa</button></td><td><?php echo"<a href=\"staff-index.php?p=staff-list-trainning-class&trnpid={$info[0]}\">Xem danh sách các lớp</a>"?></td>
</tr>
    <?php
}
?>
</table>
<?php
for ( $page = 0; $page < $sotrang; $page ++ )
{
echo "<a href='staff-index.php?p=staff-man-train-pro&page={$page}'>{$page} </a>";
} 

mysql_close();
?>
</body>
</html>

